<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class StoreDetail extends BaseModel
{
    protected $fillable = [
        'name', 'logo_url' , 'mobile', 'province', 'city',
        'county', 'address', 'business_time_start', 'business_time_end',
        'details', 'status', 'sharing_percent', 'sn', 'merchant_id'
    ];
    
    public function setLogoUrlAttribute($value)
    {
    	$this->attributes['logo_url'] = env('ALIOSS_HOST').'/'.$value;
    }

    public function store()
    {
        return $this->belongsTo(Store::class);
    }
    
    public static function setSelect()
    {
        $detail = new self();
        $arr = self::all()->pluck('name', 'store_id')->toArray();
        $arr[0] = '本部';
        ksort($arr);
        return $arr;
    }
}
